package com.shiwaixiangcun.customer.entity

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName

/**
 * Author   Administrator
 * Date     2018/4/10
 * Desc     eg
 */

/**
 * 我的房产
 */


data class MyPropertyEntity(
		@SerializedName("houseNumDesc") val houseNumDesc: String,
		@SerializedName("id") val id: Long,
		@SerializedName("unclearAmount") val unclearAmount: String
) : Parcelable {
	constructor(source: Parcel) : this(
			source.readString(),
			source.readLong(),
			source.readString()
	)

	override fun describeContents() = 0

	override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
		writeString(houseNumDesc)
		writeLong(id)
		writeString(unclearAmount)
	}

	companion object {
		@JvmField
		val CREATOR: Parcelable.Creator<MyPropertyEntity> = object : Parcelable.Creator<MyPropertyEntity> {
			override fun createFromParcel(source: Parcel): MyPropertyEntity = MyPropertyEntity(source)
			override fun newArray(size: Int): Array<MyPropertyEntity?> = arrayOfNulls(size)
		}
	}
}


/**
 * 物业缴费详情
 */

data class PropertyPaymentDetailEntity(
        @SerializedName("detail") val detail: List<MonthItemEntity>,
        @SerializedName("house") val house: String,
        @SerializedName("isExistBill") val isExistBill: Boolean,
        @SerializedName("isSupport") val isSupport: Boolean,
        @SerializedName("property") val property: String,
        @SerializedName("statementDate") val statementDate: String,
        @SerializedName("unsettledAmount") val unsettledAmount: String,
        @SerializedName("nextStatementDate") val nextStatementDate: String
) : Parcelable {
	constructor(source: Parcel) : this(
			ArrayList<MonthItemEntity>().apply { source.readList(this, MonthItemEntity::class.java.classLoader) },
			source.readString(),
			1 == source.readInt(),
			1 == source.readInt(),
			source.readString(),
			source.readString(),
            source.readString(),
            source.readString()
	)

	override fun describeContents() = 0

	override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
		writeList(detail)
		writeString(house)
		writeInt((if (isExistBill) 1 else 0))
		writeInt((if (isSupport) 1 else 0))
		writeString(property)
		writeString(statementDate)
        writeString(unsettledAmount)
        writeString(nextStatementDate)
	}

	companion object {
		@JvmField
		val CREATOR: Parcelable.Creator<PropertyPaymentDetailEntity> = object : Parcelable.Creator<PropertyPaymentDetailEntity> {
			override fun createFromParcel(source: Parcel): PropertyPaymentDetailEntity = PropertyPaymentDetailEntity(source)
			override fun newArray(size: Int): Array<PropertyPaymentDetailEntity?> = arrayOfNulls(size)
		}
	}
}

/**
 * 每月收费详情
 */

data class MonthItemEntity(
		@SerializedName("billAmount") val billAmount: String,
		@SerializedName("list") val list: List<FeeItem>,
		@SerializedName("name") val name: String,
		@SerializedName("statementId") val statementId: Int
) : Parcelable {
	constructor(source: Parcel) : this(
			source.readString(),
			ArrayList<FeeItem>().apply { source.readList(this, FeeItem::class.java.classLoader) },
			source.readString(),
			source.readInt()
	)

	override fun describeContents() = 0

	override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
		writeString(billAmount)
		writeList(list)
		writeString(name)
		writeInt(statementId)
	}

	companion object {
		@JvmField
		val CREATOR: Parcelable.Creator<MonthItemEntity> = object : Parcelable.Creator<MonthItemEntity> {
			override fun createFromParcel(source: Parcel): MonthItemEntity = MonthItemEntity(source)
			override fun newArray(size: Int): Array<MonthItemEntity?> = arrayOfNulls(size)
		}
	}
}

/**
 * 收费项目
 */

data class FeeItem(
		@SerializedName("billAmountLabel") val billAmountLabel: String,
		@SerializedName("itemId") val itemId: Int,
		@SerializedName("itemName") val itemName: String,
		@SerializedName("mainItem") val mainItem: Boolean,
		@SerializedName("paidInAmountLabel") val paidInAmountLabel: String,
		@SerializedName("unclearedAmountLabel") val unclearedAmountLabel: String
) : Parcelable {
	constructor(source: Parcel) : this(
			source.readString(),
			source.readInt(),
			source.readString(),
			1 == source.readInt(),
			source.readString(),
			source.readString()
	)

	override fun describeContents() = 0

	override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
		writeString(billAmountLabel)
		writeInt(itemId)
		writeString(itemName)
		writeInt((if (mainItem) 1 else 0))
		writeString(paidInAmountLabel)
		writeString(unclearedAmountLabel)
	}

	companion object {
		@JvmField
		val CREATOR: Parcelable.Creator<FeeItem> = object : Parcelable.Creator<FeeItem> {
			override fun createFromParcel(source: Parcel): FeeItem = FeeItem(source)
			override fun newArray(size: Int): Array<FeeItem?> = arrayOfNulls(size)
		}
	}
}


data class PaymentRecordEntity(
        @SerializedName("billAmount") val billAmount: String,
        @SerializedName("id") val id: Long,
        @SerializedName("name") val name: String,
        @SerializedName("propertyName") val propertyName: String
)


data class PaymentRecordList<T>(
		@SerializedName("list") val list: List<T>
)


data class RecordDetailEntity(
        @SerializedName("amount") val amount: String,
        @SerializedName("detail") val detail: List<Detail>,
        @SerializedName("house") val house: String,
        @SerializedName("payDate") val payDate: Long,
        @SerializedName("payWay") val payWay: String,
        @SerializedName("property") val property: String
)

data class Detail(
        @SerializedName("billAmount") val billAmount: String,
        @SerializedName("list") val list: List<FeeItem>,
        @SerializedName("name") val name: String,
        @SerializedName("statementId") val statementId: Int
)



